// 1.字符串类型 ''、 ""、``
let aName: string = "貂蝉";

// 2.数值类型
let dAge: number = 18;
dAge = 18.13;
dAge = -17;

// 3.布尔值类型  true /false
let isSingleDog: boolean = true;
isSingleDog = false;

// 4.undefined 和null
let undef: undefined = undefined;
let nul: null = null;

// 5.数组
let arrJs = [1, "a", true, [], {}]; //arrJs

let arrHero: string[] = ["安吉拉", "大桥", "貂蝉"]; //ts
let arrHeroAge: number[] = [18, 27, 30];
// 泛型
let arrHeroAge2: Array<string> = ["安吉拉", "大桥", "貂蝉"];

// 7.元组(tuple):就是一个已知元素数量和每个元素类型的数组，内部的元素类型不必相同
let tup1: [string, number, boolean] = ["讨厌，死鬼", 18, true];
tup1 = ["死鬼", 19, false];

// 访问元祖中元素和长度
console.log(tup1.length);
console.log(tup1[0]);

// 8.枚举(enum):用一组标识 来 代表数值，方便程序员调用理解
// 8.1创建性别枚举
enum Gender {
  Boy = 1,
  Girl = 2,
  Unknown = 3,
}
console.log(Gender.Boy);
console.log(Gender.Unknown);

enum Gender2 {
  Boy,
  Girl,
  Unknown,
} //不给值默认从下标开始
// 8.2使用性别枚举
let usrSex: Gender = Gender.Boy;
if (usrSex === Gender.Boy) {
  console.log("相等");
} else {
  console.log(usrSex);
}

// 1.函数返回值 类型
function sayHi(): string {
  return "hi~~ old driver";
}

let res1: string = sayHi();
// 2.函数 形参 类型
function jumpSan(cityName: string): void {
  console.log(`兄弟，跳哪里?${cityName}`);
}
jumpSan("p城");

// 2.1ts中实参必须和形参的类型一致
// 2.2ts中实参和形参的数量必须一致

// 可选参数

// 默认值
function buyGun(num = 1) {}

// 剩余参数
function add(x: number, y: number, ...restOfNum: number[]): void {}
